<template>
  <div class="container">
    <standardTable :title="title" :columns="columns" :data-source="data" :column-custom="['name', 'age', 'tags', 'action']">
      <template #extra>
        <!-- <a href="#">more</a> -->
      </template>
      <template #search>
        <a-form :layout="formLayout" :model="formState" style="margin-bottom: 20px;">
          <a-form-item label="Field A">
            <a-input v-model:value="formState.fieldA" placeholder="input placeholder" />
          </a-form-item>
          <a-form-item label="Field B">
            <a-input v-model:value="formState.fieldB" placeholder="input placeholder" />
          </a-form-item>
          <a-form-item>
            <a-button type="primary">Submit</a-button>
          </a-form-item>
        </a-form>
      </template>
      <template #tags="record">
        <a-tag
          v-for="tag in record.tags"
          :key="tag"
          :color="tag === 'loser' ? 'volcano' : tag.length > 5 ? 'geekblue' : 'green'"
        >
          {{ tag.toUpperCase() }}
        </a-tag>
      </template>
      <template #action="record">
        <span>
          <a>Invite 一 {{ record.name }}</a>
          <a-divider type="vertical" />
          <a>Delete</a>
          <a-divider type="vertical" />
          <a class="ant-dropdown-link">
            More actions
            <down-outlined />
          </a>
        </span>
      </template>
    </standardTable>
  </div>
</template>

<script setup>
import standardTable from '@/components/table/standardTable.vue';
import store from '@/store';
import { computed, reactive, ref } from 'vue';

const title = ref('基础表格')

const columns = [
  {
    title: '姓名',
    dataIndex: 'name',
  },
  {
    title: '年龄',
    dataIndex: 'age',
  },
  {
    title: '地址',
    dataIndex: 'address',
    key: 'address',
  },
  {
    title: '标签',
    key: 'tags',
    dataIndex: 'tags',
  },
  {
    title: '操作',
    key: 'action',
    dataIndex: 'action',
  },
];
const data = [
  {
    key: '1',
    name: 'John Brown',
    age: 32,
    address: 'New York No. 1 Lake Park',
    tags: ['nice', 'developer'],
  },
  {
    key: '2',
    name: 'Jim Green',
    age: 42,
    address: 'London No. 1 Lake Park',
    tags: ['loser'],
  },
  {
    key: '3',
    name: 'Joe Black',
    age: 32,
    address: 'Sidney No. 1 Lake Park',
    tags: ['cool', 'teacher'],
  },
]
const formState = reactive({
  fieldA: '',
  fieldB: '',
})
const formLayout = computed(() => {
  return store.getters['setting/isMobile'] ? 'vertical' : 'inline'
})

</script>

<style scoped>
.container{
  padding: 20px;
}
</style>